package mark.tom.gear.base.utils

import android.content.Context
import com.hundsun.gmubase.utils.SharedPreferencesManager
import com.hundsun.gmubase.widget.privacy.IOverlayPermissionCallBack
import com.hundsun.gmubase.widget.privacy.PrivacyManager
import mark.tom.gear.base.callback.CallBack

/**
 * @Description: 隐私政策工具类
 * @Author: ttmk110@163.com
 * @Package: mark.tom.gear.base.utils
 * @Date: 2021/4/2
 * @Copyright: 版权归 Mark 所有
 * <ModifyLog>
 * @ModifyContent:
 * @Author:
 * @Date:
 * </ModifyLog>
 */
object PrivacyUtil {

    /**
     * Description: 检查隐私政策是否配置
     * Copyright: Copyright (c) 2021
     * Project: Gear
     * Author: ttmk110@163.com
     * Date: 2021/4/2 17:21
     */
    fun checkPrivacyShow(): Boolean {
        return PrivacyManager.getInstance().checkPrivacyShow()
    }

    /**
     * Description: 显示隐私政策内容
     * Copyright: Copyright (c) 2021
     * Project: Gear
     * Author: ttmk110@163.com
     * Date: 2021/4/2 17:21
     */
    fun showPrivacy(mContext: Context) {
        PrivacyManager.getInstance().showPrivacy(mContext)
    }

    /**
     * Description: 检查权限提示信息是否显示过
     * Copyright: Copyright (c) 2021
     * Project: Gear
     * Author: ttmk110@163.com
     * Date: 2021/4/2 17:22
     */
    fun checkPermissionTipShow(): Boolean {
        return PrivacyManager.getInstance().checkPermissionTipShow()
    }

    /**
     * Description: 显示权限提示内容
     * Copyright: Copyright (c) 2021
     * Project: Gear
     * Author: ttmk110@163.com
     * Date: 2021/4/2 17:29
     */
    fun showPermissionTipShow(mContext: Context, resourceId: Int, mCallBack: CallBack<Any, Unit>?) {
        PrivacyManager.getInstance().showPermissionTipShow(mContext, resourceId, object :
            IOverlayPermissionCallBack {
            override fun onQuit() {
                mCallBack?.onFail("")
            }

            override fun onNext() {
                mCallBack?.onSuccess("")
            }
        })
    }

    /**
     * Description: 更新权限提示内容已读状态
     * Copyright: Copyright (c) 2021
     * Project: Gear
     * Author: ttmk110@163.com
     * Date: 2021/4/2 17:31
     */
    fun updatePermissionTipReadStatus(read: Boolean = true) {
        SharedPreferencesManager.setPreferenceValue(PrivacyManager.PERMISSIONTIPFLAG, read)
    }

    /**
     * Description: 关闭权限提示框
     * Copyright: Copyright (c) 2021
     * Project: Gear
     * Author: ttmk110@163.com
     * Date: 2021/4/2 17:31
     */
    fun dismissPermissionTip() {
        PrivacyManager.getInstance().dismissPermissionTip()
    }
}